package com.forum.model.pojo;

import java.util.Date;
import java.util.ArrayList;
import java.util.List;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.SequenceGenerator;
import javax.persistence.Table;
import javax.persistence.Transient;

@Entity
@Table(name = "topic")
@SequenceGenerator(name = "sequence", sequenceName = "topic_id_seq", allocationSize = 1)
public class Topic {

	@Id
	@GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "sequence")
	@Column(name = "id")
	private Long id;

	@Transient
	private List<Post> posts;

	@Column(name = "topicowner", nullable = false)
	private Long topicOwner;

	@Column(name = "lastpost")
	private Long lastPost;

	@Column(name = "postcount")
	private int postCount;

	@Column(name = "statusflag", nullable = false)
	private char statusFlag;

	@Column(name = "sectionname", nullable = false)
	private String sectionName;

	@Column(name = "title", nullable = false)
	private String title;

	@Column(name = "description")
	private String description;

	@Column(name = "startdate", nullable = false)
	private Date startDate;

	@Column(name = "modifydate", nullable = false)
	private Date modifyDate;

	public Topic() {
	}

	public Topic(String title, String sectionName, Date startDate,
			Date modifyDate, Long topicOwner, char statusFlag) {
		this.title = title;
		this.sectionName = sectionName;
		this.startDate = startDate;
		this.modifyDate = modifyDate;
		this.topicOwner = topicOwner;
		this.statusFlag = statusFlag;
		this.posts = new ArrayList<Post>();
	}

	public Long getId() {
		return id;
	}

	public void setId(Long id) {
		this.id = id;
	}

	public List<Post> getPosts() {
		return posts;
	}

	public String getSectionName() {
		return sectionName;
	}

	public void setSectionName(String sectionName) {
		this.sectionName = sectionName;
	}

	public String getTitle() {
		return title;
	}

	public void setTitle(String title) {
		this.title = title;
	}

	public String getDescription() {
		return description;
	}

	public void setDescription(String description) {
		this.description = description;
	}

	public char getStatusFlag() {
		return statusFlag;
	}

	public void setStatusFlag(char statusFlag) {
		this.statusFlag = statusFlag;
	}

	public Long getTopicOwner() {
		return topicOwner;
	}

	public void setTopicOwner(Long topicOwner) {
		this.topicOwner = topicOwner;
	}

	public Long getLastPost() {
		return lastPost;
	}

	public void setLastPost(Long lastPost) {
		this.lastPost = lastPost;
	}

	public int getPostCount() {
		return postCount;
	}

	public void setPostCount(int postCount) {
		this.postCount = postCount;
	}

	public void setPosts(List<Post> posts) {
		this.posts = posts;
	}

	public void setStartDate(Date startDate) {
		this.startDate = startDate;
	}

	public void setModifyDate(Date modifyDate) {
		this.modifyDate = modifyDate;
	}

	public Date getStartDate() {
		return startDate;
	}

	public Date getModifyDate() {
		return modifyDate;
	}
}